package com.project.restaurant.user.dto;

import com.project.restaurant.pojo.User;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class RegisterInfo {

    @ApiModelProperty(value = "用户名",required = true)
    @NotEmpty
    private String userName;

    @ApiModelProperty(value = "账户",required = true)
    @NotEmpty
    private String account;

    @ApiModelProperty(value = "密码",required = true)
    @NotEmpty
    private String password;

    @ApiModelProperty(value = "邮箱绑定",required = true)
    @Valid
    @NotNull
    private EmailAuthCodeParam bindingEmail;

    public User getUser(){
        User user = new User();
        BeanUtils.copyProperties(this,user);
        user.setUserEmail(this.getBindingEmail().getEmail());
        return user;
    }


}
